//异步操作，提交 mutations 来修改 state。
export default {
    selectProvince({ commit }, province) {
      commit('setSelectedProvince', province);//接收
      //commit('setCityData', cityData[province] || {});
    },
    updateEmotionsData({commit}, data) {
      commit('setEmotionsData', data);
    },
  updateCityData({commit}, data) {
    commit('setCityData', data);
  },

   //异步传值
  selectPoem({ commit }, title) {
    commit('SelectPoems', title);
    // commit('setSelectedPoem', title);
  },
  resetSelection({ commit }) {
    commit('resetSelection');
    
  },
  
  enterCover({ commit }) {
    commit('Enter')
  },

 //地图坐标
  searchPoems({ commit,state }, title) {
    const poem = state.poems.find(p => p.title === title);
    if (poem) {
      commit('setPoemLocation', {
        title: poem.title,
        place: poem.place,
        time: poem.time,
        coordinates: poem.coordinates,
      });
    }
  },
  
  //省份选择，异步传值
  selectRegion({ commit }, regionName) {
    commit('SelectRegion', regionName); // 触发 mutation 来更新状态
  },

  
  
  //当前事件
  setCurrentEvent({ commit }, event) {
    commit('SetCurrentEvent', event); // 更新当前事件  
    commit('SetLastEvent', event); // 更新上一个事件状态  
  }, 
  //清空当前事件
  clearCurrentEvent({ commit }) {
    commit('ClearCurrentEvent'); // 清空当前事件  
  },   



  
  //搜索相应的古诗名字匹配
  // searchPoem({ commit }, searchName) {
  //   const poemName = data.find(p => p.title === searchName);
  //   if (poemName) {
  //     commit('setPoem', poemName);
  //   }
  // },

  //匹配第二页地图
  // selectPoem2({ commit }, poem) {
  //   commit('setSelectedPoem', poem);
  // }, 
  // resetSelection2({ commit }) {
  //   commit('resetSelection');
  // },
}